package com.example.shipload_e.util;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;

public class SharePreferenceUtil {
	private static String	               SAVE_USER	= "saveUser";
	private final SharedPreferences	       sp;	                      //
	private final SharedPreferences.Editor	editor;	              //

	@SuppressLint("CommitPrefEdits")
	public SharePreferenceUtil(Context context, String file) {
		sp = context.getSharedPreferences(file, Context.MODE_PRIVATE);
		editor = sp.edit();
	}

	@SuppressLint("CommitPrefEdits")
	public SharePreferenceUtil(Context context) {
		sp = context.getSharedPreferences(SAVE_USER, Context.MODE_PRIVATE);
		editor = sp.edit();
	}

	// 界面名称
	public void setTitleName(String TitleName) {
		editor.putString("TitleName", TitleName);
		editor.commit();
	}

	public String getTitleName() {
		return sp.getString("TitleName", "");
	}

	// 账号名
	public void setAccount(String account) {
		editor.putString("account", account);
		editor.commit();
	}

	public String getAccount() {
		return sp.getString("account", "");
	}

	// 密码
	public void setPassword(String password) {
		editor.putString("password", password);
		editor.commit();
	}

	public String getPassword() {
		return sp.getString("password", "");
	}

	// 欢迎界面进入标志
	public boolean getIsComeFromWelcome() {
		return sp.getBoolean("IsComeFromWelcome", false);
	}

	public void setIsComeFromWelcome(boolean data) {
		editor.putBoolean("IsComeFromWelcome", data);
		editor.commit();
	}

	// 图片名称
	public void setFileName(String FileName) {
		editor.putString("FileName", FileName);
		editor.commit();
	}

	public String getFileName() {
		return sp.getString("FileName", "");
	}

	// 上传图片末端
	public boolean getIsLastIndex() {
		return sp.getBoolean("IsLastIndex", false);
	}

	public void setIsLastIndex(boolean data) {
		editor.putBoolean("IsLastIndex", data);
		editor.commit();
	}

	/**
	 * 卸船完成和装船完成跳转数据
	 */
	// 卸船完成或者装船完成跳转标志
	public void setFollowActivityName(String FollowActivityName) {
		editor.putString("FollowActivityName", FollowActivityName);
		editor.commit();
	}

	public String getFollowActivityName() {
		return sp.getString("FollowActivityName", "");
	}

	// 任务id
	public void setFollowId(String FollowId) {
		editor.putString("FollowId", FollowId);
		editor.commit();
	}

	public String getFollowId() {
		return sp.getString("FollowId", "");
	}

	// 任务参数
	public void setFollowResult(String FollowResult) {
		editor.putString("FollowResult", FollowResult);
		editor.commit();
	}

	public String getFollowResult() {
		return sp.getString("FollowResult", "");
	}

	// 任务单位
	public void setFollowUnit(String FollowUnit) {
		editor.putString("FollowUnit", FollowUnit);
		editor.commit();
	}

	public String getFollowUnit() {
		return sp.getString("FollowUnit", "");
	}

	// 任务总数量
	public void setFollowCount(String FollowCount) {
		editor.putString("FollowCount", FollowCount);
		editor.commit();
	}

	public String getFollowCount() {
		return sp.getString("FollowCount", "");
	}

	/**
	 * 从平台获取的卸船完成任务列表数据
	 */
	public void setResponseResult(String ResponseResult) {
		editor.putString("ResponseResult", ResponseResult);
		editor.commit();
	}

	public String getResponseResult() {
		return sp.getString("ResponseResult", "");
	}
}
